


// Hooks
import useToast from "./useToast";

function useDownload(fileLocation) {
  uni.hideLoading();

  uni.showLoading({
    title: "正在打开",
  });

  uni.downloadFile({
    url: fileLocation, //pdf链接
    success(res) {
      uni.openDocument({
        filePath: res.tempFilePath,
        fileType: "pdf",
        showMenu: true,
        success() {
          uni.hideLoading();
        },

        fail() {
          useToast("打开文档失败");
        },
      });
    },
    fail() {
      useToast("打开文档失败");
    },
  });
  return;
}

export default useDownload;
